<template>
  <a-modal
    :title="title"
    :width="1250"
    :visible="visible"
    @cancel="handleCancel"
    v-if="visible"
    :cancelText="$t('systemManagement.close')"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 100%;overflow-y: hidden">
    <template slot="footer">
      <a-button @click="handleCancel">{{$t('systemManagement.close')}}</a-button>
    </template>
    <!-- table区域-begin -->
    <a-table
      bordered
      ref="table"
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange">
    </a-table>
    <!-- table区域-end -->
  </a-modal>
</template>

<script>
  // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'
import { getLanCode } from '@/lang'
  export default {
    name: 'ReviewProgress',
    // mixins:[JeecgListMixin],
    components: {

    },
    data () {
      return {
        title: this.$t('purchasingManagement.ReviewProgress'),
        visible: false,
        queryParam: {
          defaultNumber: ''
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            let lanCode = getLanCode()
            if (lanCode === 'zh') {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            } else {
              return range[0] + '-' + range[1] + ' Common ' + total + ' Strip'
            }
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        // 表头
        columns: [
          {
            title: this.$t('defaultTranslate.lineNumber'), dataIndex: 'rowIndex', width:40, align:"center", customRender: (t,r,index) => parseInt(index)+1 
          },
          { 
            title: this.$t('purchasingManagement.ReviewProgress'), dataIndex: 'process',width:80, align:"center",
            customRender: text => this.$t(`purchasingManagement.ReviewProgressStep${text}`)
          },
          { title: this.$t('purchasingManagement.Auditor'), dataIndex: 'loginName',width:80, align:"center" },
          {
            title: this.$t('purchasingManagement.state'), dataIndex: 'enableFlag',width:80, align:"center", 
            customRender: text => {
              switch (text) {
                case 'pass':
                  return <a-tag color="green">{this.$t('otherJS.adopt')}</a-tag>
                case 'reject':
                  return <a-tag color="red">{this.$t('otherJS.reject')}</a-tag>
              }
            }
          },
          { title: this.$t('purchasingManagement.ReviewOpinion'), dataIndex: 'approveMsg',width:80, align:"center" },
          { title: this.$t('purchasingManagement.ReviewTime'), dataIndex: 'approveTime',width:80, align:"center" }
        ],
        dataSource:[],
        url: {
          processList: "/workflowConfigProcess/getProgressByDefaultNumber"
        }
      }
    },
    created() {
    },
    methods: {
      show(record, paramKey = 'defaultNumber') {
        this.model = Object.assign({}, record)
        this.visible = true
        this.queryParam.defaultNumber = record[paramKey]
        this.getProgressByDefaultNumber()
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      },
      
    handleTableChange (pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
      }
      if (pagination && pagination.current) {
        this.ipagination = pagination
      }
      this.loadData()
    },
      getProgressByDefaultNumber () {
        this.loading = true
        getAction(this.url.processList, this.queryParam).then(res => {
        this.loading = false
          if (res.code === 200) {
            this.dataSource = res.data
          }
        }).finally(() => {
          this.loading = false
        })
      }
    }
  }
</script>

<style scoped>

</style>